package agents;

import jade.core.Agent;
import jade.core.AID;
import jade.core.behaviours.*;

//import jade.domain.AMSService;
//import jade.domain.FIPAAgentManagement.*;

import jade.lang.acl.*;


public class Sender extends Agent 
{
    protected void setup() 
    {
	// First set-up answering behaviour
    	System.out.println("Iniciando el envio...");
	
		addBehaviour(new CyclicBehaviour(this) 
		{
			 public void action() {
				ACLMessage msg= receive();
				if (msg!=null)
					System.out.println( "\n\nEstadistica:\nLa respuesta es:" 
					 +  msg.getContent() + ". Enviada por: "
					 +  msg.getSender().getName() );
				block();
			 }
		});
		
		//Escenarios:
	
		ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
		msg.setContent( "Ping" );
     	for (int i = 1; i<=2; i++)
     		msg.addReceiver( new AID( "A"+i, AID.ISLOCALNAME) );
		send(msg);
	}
}


    